package com.songshuai.webapi.baseapi.enumerations;

public enum RelationEnum {
    Self(6002001, "本人"),
    Mother(6002002, "妈妈"),
    Father(6002003, "爸爸"),
    Grandpa(6002004, "爷爷"),
    Grandma(6002005, "奶奶"),
    Grandfather(6002006, "外公"),
    Grandmother(6002007, "外婆"),
    Other(6002008, "其他");
    private int code;
    private String msg;

    RelationEnum(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public static int getCode(String define){
        try {
            return RelationEnum.valueOf(define).code;
        } catch (IllegalArgumentException e) {
            return 0;
        }
    }

    public static String getMsg(String define){
        try {
            return RelationEnum.valueOf(define).msg;
        } catch (IllegalArgumentException e) {
            return "";
        }
    }

    public static String getMsg(Integer code){
        if(code==null||code<=0)
            return "";
        for(RelationEnum err : RelationEnum.values()){
            if(err.code==code){
                return err.msg;
            }
        }
        return "";
    }

    public int getCode(){
        return code;
    }

    public String getMsg(){
        return msg;
    }
}
